import multiprocessing as mp


def work(id, lock):
    with lock:
        print('data written by process #%s, part1' % id)
        print('data written by process #%s, part2' % id)


if __name__ == '__main__':
    data_path = 'data'
    lock = mp.Lock()
    procs = []

    for i in range(100):
        p = mp.Process(target=work, args=(i, lock))
        p.start()
        procs.append(p)

    for p in procs:
        p.join()
